<?php

namespace app\adminapi\controller\system;

use app\adminapi\service\SysLoginLogService;
use app\adminapi\validate\LoginValidate;
use app\common\controller\BaseAdminController;

class SysLoginLogController extends BaseAdminController
{
    public array $notNeedLogin = [];

    public function list()
    {
        $param = (new LoginValidate())->get()->goCheck('list');
        $result = (new SysLoginLogService())->list($param);
        return app('json')->successWithData($result);
    }

    /**
     * @title 删除登录日志
     * @businessType DELETE
     */
    public function delete()
    {
        $param = (new LoginValidate())->delete()->goCheck('delete');
        $result = (new SysLoginLogService())->deleteLoginLog(explode(",",$param['logIds']));
        return app('json')->successWithData($result);
    }

    /**
     * @title 清空登录日志
     * @businessType CLEAR
     */
    public function clear()
    {
        $result = (new SysLoginLogService())->clearLoginLog();
        return app('json')->successWithData($result);
    }
}